<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button>按钮跳转页面2</button>
    <script>
        let obj = {
            name: 'Kaisa',
            age: 20
        }
        // 将obj对象转成字符串传给下一个网页
        function oTs(obj) {
            let key = Object.keys(obj)
            let value = Object.values(obj)
            let str = key.map((item, index) => {
                return `${item}=${value[index]}`
            })
            return  str.join('&')
        }

        document.querySelector('button').onclick = () => {
            window.location.href = `跨页面传参数02.html?${oTs(obj)}`
        }
        console.log(`跨页面传参数02.html?${oTs(obj)}`)
        console.log(obj)



    </script>
</body>

</html>